package com.haohope.framework.cluster.autoconfigure;

import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.RedisIndexedSessionRepository;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

import com.haohope.framework.cache.RedisExpireCache;
import com.haohope.framework.redis.FastJsonRedisTemplate;
import com.haohope.framework.wb.buffer.RedisKVBuffer;
import com.haohope.framework.wb.buffer.RedisVarBuffer;
import com.haohope.framework.wb.buffer.RedisXwlBuffer;
import com.haohope.framework.wb.buffer.ReidsDataAuthBuffer;
import com.haohope.framework.wb.buffer.ReidsDictionaryBuffer;
import com.haohope.framework.wb.lock.RedissionDataAuthLock;
import com.haohope.framework.wb.lock.RedissionDictionaryLock;
import com.haohope.framework.wb.lock.RedissionKVLock;
import com.haohope.framework.wb.lock.RedissionUserListLock;
import com.haohope.framework.wb.lock.RedissionVarLock;
import com.haohope.framework.wb.online.RedisOnlineServiceImpl;
@Configuration
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=1800)
public class FrameworkClusterAutoConfigure {
	@Bean
	public RedisOnlineServiceImpl redisOnlineService(RedisIndexedSessionRepository fastJsonRedisTemplate) {
		return new RedisOnlineServiceImpl(fastJsonRedisTemplate);
	}
	/**
	@Bean
	public RedisControlsBuffer redisControlsBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		1238888
		return new RedisControlsBuffer(fastJsonRedisTemplate);
	}
	**/
	@Bean
	public RedisXwlBuffer reidsXwlBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new RedisXwlBuffer(fastJsonRedisTemplate);
	}
	@Bean
	public ReidsDictionaryBuffer redisDictionaryBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new ReidsDictionaryBuffer(fastJsonRedisTemplate);
	}
	@Bean
	public ReidsDataAuthBuffer reidsDataAuthBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new ReidsDataAuthBuffer(fastJsonRedisTemplate);
	}
	@Bean
	public RedisVarBuffer redisVarBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new RedisVarBuffer(fastJsonRedisTemplate);
	}
	@Bean
	public RedisKVBuffer redisKVBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new RedisKVBuffer(fastJsonRedisTemplate);
	}
	/**
	@Bean
	public RedisFileBuffer ReidsFileBuffer(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new RedisFileBuffer(fastJsonRedisTemplate);
	}**/
	@Bean
	public RedissionDataAuthLock dataAuthLock(RedissonClient redissonClient){
		return new RedissionDataAuthLock(redissonClient);
	}
	@Bean
	public RedissionDictionaryLock dictionaryLock(RedissonClient redissonClient) {
		return new RedissionDictionaryLock(redissonClient);
	}
	@Bean
	public RedissionKVLock kvLock(RedissonClient redissonClient) {
		return new RedissionKVLock(redissonClient);
	}
	@Bean
	public RedissionUserListLock userListLock(RedissonClient redissonClient) {
		return new RedissionUserListLock(redissonClient);
	}
	@Bean
	public RedissionVarLock varLock(RedissonClient redissonClient) {
		return new RedissionVarLock(redissonClient);
	}
	@Bean
	public RedisExpireCache redisExpireCache(FastJsonRedisTemplate fastJsonRedisTemplate) {
		return new RedisExpireCache(fastJsonRedisTemplate,"accesslog",5 * 60);
	}
}
